<!--
http://paulirish.com/2011/requestanimationframe-for-smart-animating/
-->
moving
<script>
// requestAnim shim layer by Paul Irish
    window.requestAnimFrame = (function(){
      return  window.requestAnimationFrame       || 
              window.webkitRequestAnimationFrame || 
              window.mozRequestAnimationFrame    || 
              window.oRequestAnimationFrame      || 
              window.msRequestAnimationFrame     || 
              function(/* function */ callback, /* DOMElement */ element){
                window.setTimeout(callback, 1000 / 60);
              };
    })();
  

// example code from mr doob : http://mrdoob.com/lab/javascript/requestanimationframe/

var canvas, context;

init();
animate();
var t0 = new Date().getTime()
window.dots = new Array()

window.dots.push({
  x:10,
  y:20,
  phi: 1
})
alert("top " + window.dots)

function init() {

    canvas = document.createElement( 'canvas' );
    canvas.width = 256;
    canvas.height = 256;

    context = canvas.getContext( '2d' );

    document.body.appendChild( canvas );

}

function animate() {
    requestAnimFrame( animate );
    draw();

}

function drawDots(){
  //alert("drawDots "+window.dots)
  for( i in window.dots ){
    var d = window.dots[i]
    context.fillStyle = "rgb(0,0,255)";
    context.fillRect( d.x, d.y, 1, 1 );
    d.x += Math.cos(d.phi)
    d.y += Math.sin(d.phi)
  }
}

function newDots(x,y){
  //alert("newDots "+window.dots)
  var ds = window.dots
  for( i in ds ){
  }
 for( var p = 0; p < 3*2; p++ ){
   ds.length
/*
  ds.push({
   x:10,
   y:20,
   phi: 2
  })
*/
 }
}

function draw() {

    var time = new Date().getTime() - t0;
    var x = time/100;
    var y = 128;

    context.fillStyle = 'rgb(245,245,245)';
    context.fillRect( 0, 0, 255, 255 );

    drawDots()
    newDots(x,y)    

    context.fillStyle = 'rgb(255,0,0)';
    context.beginPath();
    context.arc( x, y, 10, 0, Math.PI * 2, true );
    context.closePath();
    context.fill();

}

</script>
